home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.006.DLog / dlog1.aii next >
Encoding:
Text File  |  1990-06-24  |  21.9 KB  |  897 lines  |  [TEXT/MPS ]

  1. *******************************************************************************
  2. *
  3. * DLog1 -- Version 3.0
  4. *
  5. * (C)  Copyright Apple Computer, Inc. 1988-1990
  6. * All rights reserved.
  7. *
  8. * Developer Technical Support Apple II Sample Code
  9. *
  10. * by Jim Mensch
  11. *
  12. * Demo of the Apple IIgs Dialog manager. This program shows how to create and 
  13. * work with standard dialog boxes, both Modal and Modeless. It also has a demo
  14. * of simple alerts. The dialogs used are from the examples in the toolbox ref
  15. * manual volume 1. The Modal example implements a save current value feature.
  16. *
  17. *******************************************************************************
  18. **********************************************************************
  19. *                                                                    *
  20. *     This program and its derivatives are licensed only for         *
  21. *     use on Apple computers.                                        *
  22. *                                                                    *
  23. *     Works based on this program must contain and                   *
  24. *     conspicuously display this notice.                             *
  25. *                                                                    *
  26. *     This software is provided for your evaluation and to           *
  27. *     assist you in developing software for the Apple IIGS           *
  28. *     computer.                                                      *
  29. *                                                                    *
  30. *     DISCLAIMER OF WARRANTY                                         *
  31. *                                                                    *
  32. *     THE SOFTWARE IS PROVIDED "AS IS" WITHOUT                       *
  33. *     WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,               *
  34. *     WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS             *
  35. *     FOR ANY PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO             *
  36. *     THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH            *
  37. *     YOU.  SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU (AND            *
  38. *     NOT APPLE OR AN APPLE AUTHORIZED REPRESENTATIVE)               *
  39. *     ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING,             *
  40. *     REPAIR OR CORRECTION.                                          *
  41. *                                                                    *
  42. *     Apple does not warrant that the functions                      *
  43. *     contained in the Software will meet your requirements          *
  44. *     or that the operation of the Software will be                  *
  45. *     uninterrupted or error free or that defects in the             *
  46. *     Software will be corrected.                                    *
  47. *                                                                    *
  48. *     SOME STATES DO NOT ALLOW THE EXCLUSION                         *
  49. *     OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSION MAY              *
  50. *     NOT APPLY TO YOU.  THIS WARRANTY GIVES YOU SPECIFIC            *
  51. *     LEGAL RIGHTS AND YOU MAY ALSO HAVE OTHER RIGHTS                *
  52. *     WHICH VARY FROM STATE TO STATE.                                *
  53. *                                                                    *
  54. *                                                                    *
  55. **********************************************************************
  56.     eject
  57.     
  58.     PRINT NOGEN,NOHDR
  59.     STRING AsIS
  60.     case   on
  61.  
  62.     PRINT PUSH,OFF
  63.     include 'M16.Util'
  64.     include 'M16.ProDOS'
  65.     include 'M16.QUICKDRAW'
  66.     include 'E16.Quickdraw'
  67.     include 'M16.MEMORY'
  68.     include 'E16.Memory'
  69.     include 'M16.EVENT'
  70.     include 'M16.LOCATOR'
  71.     include 'M16.MISCTOOL'
  72.     include 'M16.TextTOOL'
  73.     include 'M16.Menu'
  74.     include 'M16.Control'
  75.     include 'E16.Window'
  76.     include 'M16.Window'
  77.     include 'M16.Dialog'
  78.     include 'E16.Dialog'
  79.     include 'M16.LineEdit'
  80.     include 'M16.List'
  81.     include 'M16.IntMath'
  82.     include 'M16.Scrap'
  83.     include 'M16.Desk'
  84.     PRINT ON
  85.  
  86. DPHandle    equ 0    ; handle to Tool Direct Page area
  87. DPPointer    equ DPHandle+4    ; Pointer to Tool Direct Page area
  88. DeRef    equ DPPointer+4    ; Temprary Handle dereference area
  89. ScreenMode    equ mode640    ; used to set scan line SCB
  90. ScreenWidth    equ 640    ; used to set mouse    clamps       
  91.  
  92. CloseItem    equ 255    ; menu item number for close item
  93.  
  94.     EJECT
  95. *******************************************************************************
  96. *
  97. DLog1    PROC
  98. *
  99. * Description:    This is the main routine of the program. It simply calls
  100. *    all the other major parts of the program.
  101. *
  102. *
  103. * Inputs:    None
  104. *
  105. * Outputs:    None
  106. *
  107. * External Refs:
  108.     import InitTools, InitApp, EventLoop, CloseTools, QuitParms
  109. *
  110. * Entry Points:    None
  111. *
  112. *******************************************************************************
  113.  
  114.  
  115.     jsr InitTools
  116.     jsr InitApp
  117.  
  118.     _ShowCursor
  119.  
  120.     jsr EventLoop
  121.     jsr CloseTools
  122.  
  123.     _Quit QuitParms
  124.  
  125.     EndP
  126.  
  127.     EJECT
  128. *******************************************************************************
  129. *
  130. Globals    RECORD
  131. *
  132. * Description:    Global data for use in all routines of this demo. This area
  133. *    also contains the data used by StandardLib.aii    
  134. *
  135. *
  136. * Inputs:    None
  137. *
  138. * Outputs:    None
  139. *
  140. * External Refs:    None
  141. *
  142. * Entry Points:
  143.     export QuitParms    ; used by Main
  144. *
  145. *******************************************************************************
  146. *
  147. * Standard global data
  148. *
  149. *******************************************************************************
  150.  
  151. TitleString    str 'Apple IIgs Dialog Mgr Example Application'
  152. AutString    str 'By Mensch Apple DTS -- Version: 3.0'
  153. VersString    str 'Copyright (C) 1988-1990 Apple Computer'
  154.  
  155. MenuHeight    ds.B 2    ; Stored height of menu bar
  156. MyID    ds.B 2    ; Application ID
  157. MyDP    ds.B 2    ; My direct page storage
  158.  
  159. QuitFlag    ds.B 2
  160. QuitParms    dc.L 0    ; Pathname of next app
  161.     dc.W $00    ; flags
  162.  
  163. EventRecord
  164. EventWhat    ds.B 2
  165. EventMessage    ds.B 4
  166. EventWhen    ds.B 4
  167. EventWhere    ds.B 4
  168. EventModifiers    ds.B 2
  169. TaskData    ds.B 4
  170. TaskMask    dC.L $0000FFFF
  171.  
  172.     EJECT
  173. *******************************************************************************
  174. *
  175. * Application specific global data
  176. *
  177. *******************************************************************************
  178.  
  179. ; This is a list of pointers to the text that is used to create our menus. It
  180. ; is used by InitApp to find all of the menu templates and use them to create
  181. ; our menubar. This loop loads MenuPtrLen-4 into an index, gets the
  182. ; corresponding menu template pointer in this table, and uses that in a
  183. ; NewMenu call. It then decrements the index by 4, and repeats the procees
  184. ; until the index is negative.
  185.  
  186. MenuPtr    dc.l AppMenu
  187.     dc.l FileMenu
  188.     dc.l EditMenu
  189. MenuPtrLen    equ *-MenuPtr
  190.  
  191.  
  192. ; Menu list: menu items should be numbered consecutivly starting from 250.
  193. ; As a convention, use 256 as about and 257 as Quit.
  194.  
  195. AppMenu    dc.B '$$@\XN1',$0D
  196.     dc.B '--About Simple Dialog...\N256V',$00
  197.     dc.B '.'
  198. FileMenu    dc.B '$$  File  \N2',$00
  199.     dc.B '--Modal Dialog Sample...\N258',$00
  200.     dc.B '--Modeless Dialog Sample...\N259',$00
  201.     dc.B '--Close\N255DV',$00
  202.     dc.B '--Quit\N257*Qq',$0D
  203.     dc.B '.'
  204. EditMenu    dc.B '$$  Edit  \N3',$00
  205.     dc.B '--Undo\N250*ZzVD',$00
  206.     dc.B '--Cut\N251*XxD',$00
  207.     dc.B '--Copy\N252*CcD',$00
  208.     dc.B '--Paste\N253*VvD',$00
  209.     dc.B '--Clear\N254D',$00
  210.     dc.B '.'
  211.  
  212. ; ModalTemplate is the template described in the Toolbox reference to be used
  213. ; with the getNewModalDialog call
  214.  
  215. ModalTemplate
  216.     dc.W 30,30,120,330    ; for 320 use 30,30,130,290
  217.     dc.W $FFFF    ; visible
  218.     dc.L 0
  219.     dc.L MTOKButton    ; the ok button for    this dialog
  220.     dc.L MTCancelButton    ; cancel button
  221.     dc.L MTTitle1    ; title string of the dialog
  222.     dc.L MTTitle2    ; Title string of the Edit item
  223.     dc.L MTRadio1    ; Standard paper item
  224.     dc.L MTRadio2    ; legal pad item
  225.     dc.L MTCheck    ; stop printing item
  226.     dc.L MTEdit    ; edit box for page    title
  227.     dc.L 0    ; end of the item list
  228.  
  229. OKBTitle    str 'OK'
  230. CancelBTitle    str 'Cancel'
  231. MTTitle1Str    str 'Print the document'
  232. MTTitle2Str    str 'Title:'
  233. MTCheckStr    str 'Stop printing after each page'
  234. MTRadio1Str    str '8 1/2" x 11" paper'
  235. MTRadio2Str    str '8 1/2" x 14" paper'
  236. MTDefaultStr    ds.B 65
  237. MTOKButton
  238.     dc.W 1    ; Item ID
  239.     dc.W 30,220,43,285    ; Item rectangle
  240.     dc.W buttonItem    ; Item type
  241.     dc.L OKBTitle    ; Item Descriptor (    title )
  242.     dc.W 0    ; Initial value
  243.     dc.W 0    ; item flag ( 0 for    default )
  244.     dc.L 0    ; no color table
  245.  
  246. MTCancelButton
  247.     dc.W 2
  248.     dc.W 10,220,23,285
  249.     dc.W buttonItem
  250.     dc.L CancelBTitle
  251.     dc.W 0
  252.     dc.W 0    ; item flag
  253.     dc.L 0    ; no color table
  254.  
  255. MTTitle1
  256.     dc.W 3
  257.     dc.W 10,10,20,239
  258.     dc.W statText+itemDisable
  259.     dc.L MTTitle1Str
  260.     dc.W 0
  261.     dc.W 0    ; item flag
  262.     dc.L 0    ; no color table
  263.  
  264. MTTitle2
  265.     dc.W 4
  266.     dc.W 67,10,77,60
  267.     dc.W statText+itemDisable
  268.     dc.L MTTitle2Str
  269.     dc.W 0
  270.     dc.W 0    ; item flag
  271.     dc.L 0    ; no color table
  272.  
  273. MTRadio1
  274.     dc.W 5
  275.     dc.W 25,10,34,239
  276.     dc.W radioItem
  277.     dc.L MTRadio1Str
  278. MTRad1Def    dc.W 1    ; default to on
  279.     dc.W 1    ; family 1
  280.     dc.L 0
  281.  
  282. MTRadio2
  283.     dc.W 6
  284.     dc.W 35,10,49,239
  285.     dc.W radioItem
  286.     dc.L MTRadio2Str
  287. MTRad2Def    dc.W 0    ; default to off                
  288.     dc.W 1    ; family 1
  289.     dc.L 0
  290.  
  291. MTCheck
  292.     dc.W 7
  293.     dc.W 50,10,64,280
  294.     dc.W checkItem
  295.     dc.L MTCheckStr
  296. MTCheckDef    dc.W 0
  297.     dc.W 0
  298.     dc.L 0
  299.  
  300. MTEdit
  301.     dc.W 8
  302.     dc.W 65,65,80,280
  303.     dc.W editLine
  304.     dc.L MTDefaultStr
  305.     dc.W 60    ; max length
  306.     dc.W 0
  307.     dc.L 0
  308.  
  309. BColorTab        ; color table for use with color buttons
  310.     dc.W $0050    ; bttnOutline blue/red
  311.     dc.W $00F0    ; bttnNorBack white    background
  312.     dc.W $00A0    ; bttnSelBack yellow/green
  313.     dc.W $00F0    ; bttnNorText Black    text on White
  314.     dc.W $00A0    ; bttnSelText Black    on yellow/green
  315. ;
  316. ;   Modeless Dialog    Data 
  317. ;
  318. ModelessPtr    ds.B 4
  319. MLRect    dc.W 30,30,110,330    ; for 320 use 30,30,130,290
  320. MLTitle    str 'Change'
  321. DLogHit    ds.B 4
  322. DLogItemHit    ds.B 4
  323.  
  324.     EndR
  325.  
  326.     include 'StandardLib.Aii'
  327.     
  328.     EJECT
  329. *******************************************************************************
  330. *
  331. InitApp    PROC
  332. *
  333. * Description:    This routine is called once after the tools are started.
  334. *    This is where you would create objects your program will
  335. *    need at the very start, or initialize variables that require
  336. *    an Initial default value.
  337. *
  338. *
  339. * Inputs:    None
  340. *
  341. * Outputs:    None
  342. *
  343. * External Refs:
  344.     With Globals
  345. *
  346. * Entry Points:    None
  347. *
  348. *******************************************************************************
  349.  
  350.     Stz QuitFlag    ; initialize the quit flag
  351.     stz ModelessPtr    ; zero the modeless    pointer to signify
  352.     stz ModelessPtr+2    ; it is not already up
  353.  
  354.     rts
  355.     EndP
  356.  
  357.  
  358.     EJECT
  359. *******************************************************************************
  360. *
  361. EventLoop    PROC
  362. *
  363. * Description:    Main event loop. Handles all user events and calls various
  364. *    routines based on them. This routine ends when the user 
  365. *    selects Quit.
  366. *    
  367. *
  368. *
  369. * Inputs:    None
  370. *
  371. * Outputs:    None
  372. *
  373. * External Refs:
  374.     With Globals
  375.     Import ModelessEvent
  376.     Import MenuSelect
  377.     Import doClose
  378.     Import Ignore
  379. *
  380. * Entry Points:    None
  381. *
  382. *******************************************************************************
  383.     
  384.     PushWord #0    ; room for result
  385.     PushWord #$FFFF    ; handle all tasks
  386.     PushLong #EventRecord ; pointer to event record storage
  387.     _TaskMaster
  388.     
  389. ; Now that an event has occured we have to see if it is a dialog event. I do
  390. ; this by setting up a table of all possible events and specifying for each
  391. ; event type, whether it should be tested as a dialog event. If it turns out to
  392. ; be a dialog event, I change the EventType variable to 15 (app event 4)
  393. ; and proceed with my normal event dispatch. This will cause the event to be
  394. ; passed to my dialog event handler.
  395.  
  396.     pla    ; get the event type
  397.     sta EventType    ; save it for after    dialog select
  398.     tax    ; use as index into    dlog event flags
  399.     lda DLogEFlags,x    ; to see if its an event dialogs
  400.     and #$00FF    ; might want
  401.     bne EL0010    ; nope branch around this!
  402.  
  403.     PushWord #0
  404.     PushLong #EventRecord
  405.     _IsDialogEvent
  406.     pla
  407.     beq EL0010    ; false do nothing
  408.     lda #15    ; if true dispatch application event
  409.     sta EventType    ; #15 to signal a dialog event
  410. EL0010
  411.     lda EventType
  412.     asl a    ; multiply by 2
  413.     tax
  414.     jsr (TaskTable,x)
  415.  
  416.     lda QuitFlag
  417.     beq EventLoop
  418.  
  419.     rts
  420. EventType    ds.B 2
  421. TaskTable    dc.W ModelessEvent    ; 0 Null
  422.     dc.W Ignore    ; 1 MouseDown
  423.     dc.W Ignore    ; 2 Mouse Up
  424.     dc.W Ignore    ; 3 KeyDown
  425.     dc.W Ignore    ; 4 Undefined
  426.     dc.W Ignore    ; 5 AutoKey
  427.     dc.W Ignore    ; 6 Update
  428.     dc.W Ignore    ; 7 undefined
  429.     dc.W Ignore    ; 8 activate
  430.     dc.W Ignore    ; 9 Switch
  431.     dc.W Ignore    ; 10 desk acc
  432.     dc.W Ignore    ; 11 device driver
  433.     dc.W Ignore    ; 12 ap
  434.     dc.W Ignore    ; 13 ap
  435.     dc.W Ignore    ; 14 ap
  436.     dc.W ModelessEvent    ; 15 ap
  437.     dc.W Ignore    ; TASK 0 indesk
  438.     dc.W MenuSelect    ; TASK 1 in menuBar
  439.     dc.W Ignore    ; TASK 2 in system window
  440.     dc.W Ignore    ; TASK 3 in content
  441.     dc.W Ignore    ; TASK 4 in Drag
  442.     dc.W Ignore    ; TASK 5 in grow
  443.     dc.W doClose    ; TASK 6 in goaway
  444.     dc.W Ignore    ; TASK 7 in zoom
  445.     dc.W Ignore    ; TASK 8 in info bar
  446.     dc.W MenuSelect    ; TASK 9 in special    menu
  447.     dc.W Ignore    ; TASK 10 in NDA
  448.     dc.W Ignore    ; TASK 11 in frame
  449.     dc.W Ignore    ; TASK 12 in drop            
  450. DLogEFlags
  451.     dc.B 0    ; null event
  452.     dc.B 0    ; 1 MouseDown
  453.     dc.B 0    ; 2 Mouse Up
  454.     dc.B 0    ; 3 KeyDown
  455.     dc.B 1    ; 4 Undefined
  456.     dc.B 0    ; 5 AutoKey
  457.     dc.B 0    ; 6 Update
  458.     dc.B 1    ; 7 undefined
  459.     dc.B 0    ; 8 activate
  460.     dc.B 1    ; 9 Switch
  461.     dc.B 1    ; 10 desk acc
  462.     dc.B 1    ; 11 device driver
  463.     dc.B 1    ; 12 ap
  464.     dc.B 1    ; 13 ap
  465.     dc.B 1    ; 14 ap
  466.     dc.B 0    ; 15 ap
  467.     dc.B 1    ; TASK 0 indesk
  468.     dc.B 1    ; TASK 1 in menuBar
  469.     dc.B 1    ; TASK 2 in system window
  470.     dc.B 0    ; TASK 3 in content
  471.     dc.B 1    ; TASK 4 in Drag
  472.     dc.B 1    ; TASK 5 in grow
  473.     dc.B 1    ; TASK 6 in goaway
  474.     dc.B 1    ; TASK 7 in zoom
  475.     dc.B 1    ; TASK 8 in info bar
  476.     dc.B 1    ; TASK 9 in special    menu
  477.     dc.B 1    ; TASK 10 in NDA
  478.     dc.B 1    ; TASK 11 in frame
  479.     dc.B 1    ; TASK 12 in drop            
  480.     EndP
  481.  
  482.  
  483.     EJECT
  484. *******************************************************************************
  485. *
  486. MenuSelect    PROC
  487. *
  488. * Description:    This routine is called when TaskMaster returns a menu
  489. *    event. It takes the menu item that was hit and calculates
  490. *    an offset into the menu dispatch table. It then calls that
  491. *    routine and unhilites the menu when it is done.
  492. *
  493. * Inputs:    TaskData holds menu item selected.
  494. *
  495. * Outputs:    NONE
  496. *
  497. * External Refs:
  498.     import ignore
  499.     import doAbout
  500.     import doQuit
  501.     import Ignore
  502.     Import doModal
  503.     import ShowModeless
  504.     Import doClose
  505. *
  506. * Entry Points:    NONE
  507. *
  508. *******************************************************************************
  509.     With Globals
  510.  
  511.     lda TaskData    ; Get the ID of the menu item selected.
  512.     sec    ; Turn it into an index by subtracting
  513.     sbc #250    ; the starting ID number (25) and mul-
  514.     asl a    ; tiplying by 2 (each table entry con-
  515.     tax    ; sists of 2 bytes).
  516.     jsr (MenuTable,x)    ; Call the routine behind it.
  517.  
  518.     PushWord #0    ; Routine done - unhilite the menubar.
  519.     PushWord TaskData+2
  520.     _HiLiteMenu
  521.  
  522.     rts
  523.  
  524. MenuTable    dc.W Ignore    ; Undo Item (250)
  525.     dc.W Ignore    ; cut
  526.     dc.W Ignore    ; copy
  527.     dc.W Ignore    ; paste
  528.     dc.W Ignore    ; clear
  529.     dc.W doClose    ; close 
  530.     dc.W doAbout    ; about shell...
  531.     dc.W doQuit    ; quit selected
  532.     dc.W doModal    ; example Modal Dialog
  533.     dc.W ShowModeless    ; example Modeless Dialog
  534.  
  535.     ENDP
  536.  
  537.     EJECT
  538. *******************************************************************************
  539. *
  540. Ignore    PROC
  541. *
  542. * Description:    Called when I want to ignore an event.
  543. *
  544. *
  545. * Inputs:    NONE
  546. *
  547. * Outputs:    NONE
  548. *
  549. * External Refs:    NONE
  550. *
  551. * Entry Points:    NONE
  552. *
  553. *******************************************************************************
  554.  
  555.     rts
  556.     ENDP
  557.  
  558.  
  559.     EJECT
  560. *******************************************************************************
  561. *
  562. doQuit    PROC
  563. *
  564. * Description:    Sets the quitflag to $FFFF so that the event loop will
  565. *    know that the user wants to stop this app.
  566. *
  567. *
  568. * Inputs:    None
  569. *
  570. * Outputs:    None
  571. *
  572. * External Refs:    None
  573. *
  574. * Entry Points:    None
  575. *
  576. *******************************************************************************
  577.     With Globals
  578.  
  579.     lda #$FFFF
  580.     sta QuitFlag
  581.     rts
  582.     EndP
  583.  
  584.     EJECT
  585. *******************************************************************************
  586. *
  587. doClose    PROC
  588. *
  589. * Description:    When the user selects the Close box of our modeless dialog or
  590. *    the close menu Item. This routine will be called to put the dialog
  591. *    away and clear the pointer to 0 to indicate that no Modeless dialog
  592. *    is currently active.
  593. *
  594. *
  595. * Inputs:    None
  596. *
  597. * Outputs:    None
  598. *
  599. * External Refs:    None
  600. *
  601. * Entry Points:    None
  602. *
  603. *******************************************************************************
  604.     With Globals
  605.  
  606.     PushLong ModelessPtr
  607.     _CloseDialog    ; dump the dialog box
  608.  
  609.     stz ModelessPtr    ; zero the pointer to show that it 
  610.     stz ModelessPtr+2    ; is put away!
  611.  
  612.     PushWord #CloseItem    ; windows gone diable close
  613.     _DisableMItem    ; 
  614.  
  615.     rts
  616.     EndP
  617.  
  618.     EJECT
  619. *******************************************************************************
  620. *
  621. ModelessEvent    PROC
  622. *
  623. * Description:    This routine will be called every time an event occurs that
  624. *    a modeless dialog should hear about. First, this routine 
  625. *    checks to see if any modeless dialog exists, if not it  
  626. *    exits. If one does exist, this routine handles the event.
  627. *
  628. *
  629. * Inputs:    None  (All info passed in the event record)    
  630. *
  631. * Outputs:    None
  632. *
  633. * External Refs:    None
  634. *
  635. * Entry Points:    None
  636. *
  637. *******************************************************************************
  638.     With Globals
  639.  
  640.     lda ModelessPtr
  641.     ora ModelessPtr+2    ; test to see if dialog exists first
  642.     bne MLE0010    ; if non-zero then its up
  643.     rts
  644.  
  645. MLE0010
  646.     PushWord #0    ; room for result
  647.     PushLong #EventRecord ; pointer to the event that occured
  648.     PushLong #DLogHit    ; Storage for the dialogs grafport 
  649.     PushLong #DLogItemHit ; pointer to the item that was hit
  650.     _DialogSelect
  651.     pla    ; anything hit?
  652.     bne MLE0100    ; if so handle the hit
  653.     rts    ; else DialogSelect    did what was needed
  654.  
  655. MLE0100
  656.     _Sysbeep    ; beep on any selected item
  657.  
  658.     rts    ; go back to the event loop
  659.     EndP
  660.  
  661.     EJECT
  662. *******************************************************************************
  663. *
  664. ShowModeless    PROC
  665. *
  666. * Description:    Called when the user wants to display the modeless dialog.
  667. *    If the dialog is already displayed, this routine does nothing.
  668. *
  669. *
  670. * Inputs:    None
  671. *
  672. * Outputs:    None
  673. *
  674. * External Refs:    None
  675. *
  676. * Entry Points:    None
  677. *
  678. *******************************************************************************
  679.     With Globals
  680.  
  681.     lda ModelessPtr    ; first test to see    if box
  682.     ora ModelessPtr+2    ; is already up
  683.     beq DML0010    ; if 0 then its not    up
  684.     rts    ; if nonzero then it is
  685. DML0010
  686.     PushLong #0    ; room for result
  687.     PushLong #MLRect    ; bounds rect pointer
  688.     PushLong #MLTitle    ; box title
  689.     PushLong #-1    ; behind pointer (-1, in front of all)
  690.     pushWord #fTitle+fClose+fMove+fVis ; dFlag
  691.     PushLong #0    ; ref con of dialog
  692.     PushLong #0    ; zoomed rectangle,    0= no zooming
  693.     _NewModelessDialog
  694.     PullLong ModelessPtr ; store the result    in dialog ptr
  695.  
  696.     PushLong ModelessPtr ; now add the dialog items
  697.     PushLong #MLINext    ; first add the next button
  698.     _GetNewDItem
  699.  
  700.     PushLong ModelessPtr
  701.     PushLong #MLIAll
  702.     _GetNewDItem
  703.  
  704.     PushLong ModelessPtr
  705.     PushLong #MLIStat1
  706.     _GetNewDItem
  707.  
  708.     PushLong ModelessPtr
  709.     PushLong #MLIStat2
  710.     _GetNewDItem
  711.  
  712.     PushLong ModelessPtr
  713.     PushLong #MLIEdit1
  714.     _GetNewDItem
  715.  
  716.     PushLong ModelessPtr
  717.     PushLong #MLIEdit2
  718.     _GetNewDItem
  719.  
  720.     PushWord #CloseItem    ; we now have the dialog up so 
  721.     _EnableMItem    ; enable the close menu item
  722.  
  723.     rts
  724. MLINextStr    str 'Change Next'
  725. MLIAllStr    str 'Change All'
  726. MLIStat1Str    str 'Find Text:'
  727. MLIStat2Str    str 'Change to:'
  728. MLIDefault    str ''
  729. MLIEData1    dc.B 31    ; data max will be 30 characters
  730. MLIEData2    dc.B 31    ; data max will be 30 characters
  731. MLINext        ; Item Templates
  732.     dc.W 1    ; Item 1
  733.     dc.W 55,10,70,120    ; bounding rectangle
  734.     dc.W buttonItem    ; Item Type
  735.     dc.L MLINextStr    ; descriptor ( title )
  736.     dc.W 0    ; initial value
  737.     dc.W 0    ; item flag
  738.     dc.L BColorTab    ; Custom color table
  739.  
  740. MLIAll
  741.     dc.W 2
  742.     dc.W 55,180,70,290
  743.     dc.W buttonItem
  744.     dc.L MLIAllStr
  745.     dc.W 0
  746.     dc.W 3    ; Single outline square dropshadow
  747.     dc.L BColorTab    ; Custom color table
  748.  
  749. MLIStat1
  750.     dc.W 3
  751.     dc.W 12,10,22,90
  752.     dc.W statText+itemDisable
  753.     dc.L MLIStat1Str
  754.     dc.W 0
  755.     dc.W 0    ; item flag
  756.     dc.L 0    ; default color table
  757.  
  758. MLIStat2
  759.     dc.W 4
  760.     dc.W 32,10,42,90
  761.     dc.W statText+itemDisable
  762.     dc.L MLIStat2Str
  763.     dc.W 0
  764.     dc.W 0    ; item flag
  765.     dc.L 0    ; default color table
  766.  
  767. MLIEdit1
  768.     dc.W 5
  769.     dc.W 10,100,25,290
  770.     dc.W editLine+itemDisable
  771.     dc.L 0    ; 0 for no default text
  772.     dc.W 30    ; maximum length
  773.     dc.W 0    ; item flag
  774.     dc.L 0    ; default color table
  775.  
  776. MLIEdit2
  777.     dc.W 6
  778.     dc.W 30,100,45,290
  779.     dc.W editLine+itemDisable
  780.     dc.L MLIDefault    ; default string
  781.     dc.W 30
  782.     dc.W 0    ; item flag
  783.     dc.L 0    ; default color table
  784.  
  785.  
  786.     EndP
  787.  
  788.     EJECT
  789. *******************************************************************************
  790. *
  791. doModal    PROC
  792. *
  793. * Description:    Displays the modal Dialog and handles all events that
  794. *    occur until the OK or Cancel buttons are pressed. If the
  795. *    OK button is pressed, this routine also copies the current
  796. *    data from some of the items into the item default area so
  797. *    the next time the dialog box is brought up, it reflects the
  798. *    users last selections.
  799. *
  800. *
  801. * Inputs:    None
  802. *
  803. * Outputs:    None
  804. *        
  805. * External Refs:    None
  806. *
  807. * Entry Points:    None
  808. *
  809. *******************************************************************************
  810.     With Globals
  811.  
  812.     PushLong #0    ; room for result
  813.     PushLong #ModalTemplate ; pointer to dialog template
  814.     _GetNewModalDialog
  815.     PullLong DialogHandle ; pull Dialog pointer for later
  816.  
  817. ModalLoop
  818.     PushWord #0    ; Space for result
  819.     PushLong #0    ; Filter procedure ( 0 for none )
  820.     _ModalDialog
  821.     pla
  822.     sta ItemHit
  823.  
  824.     cmp #3    ; test if its an exit condition
  825.     blt ModalDone    ; is so, then we are done   
  826.     cmp #7    ; see if the check box was hit
  827.     bne ML0010    ; if not test more
  828.     brl ModalCheckHit    ; the check box was    hit
  829. ML0010
  830.     blt ModalRadioHit    ; one of the radio buttons was hit
  831.     brl ModalLoop    ; This should bever    happen!
  832.  
  833. ModalDone
  834.     cmp #1    ; was it the OK button?
  835.     bne MD0020    ; no, then Don't save or act on changes
  836.     jsr SetIt    ; else, reset defaults
  837. MD0020
  838.     PushLong DialogHandle ; get rid of the dialog box
  839.     _CloseDialog
  840.     rts
  841.  
  842. ModalRadioHit
  843. ; This routine sets the selected radio button. NOTE: since the radio buttons
  844. ; have the same family number, this routine also resets the other buttons.
  845.  
  846.     Pushword #$FFFF    ; now set selected button
  847.     PushLong DialogHandle
  848.     PushWord ItemHit
  849.     _SetDItemValue
  850.     brl ModalLoop
  851.  
  852. ModalCheckHit        ; Handle a hit in the check box
  853.     PushWord #0
  854.     PushLong DialogHandle
  855.     PushWord ItemHit
  856.     _GetDItemValue    ; first get the existing value
  857.     pla    ; retrieve the value
  858.     and #$0001    ; strip off all high bits
  859.     eor #$0001    ; and toggle bit 0
  860.     pha    ; now use it as the    new value
  861.     PushLong DialogHandle
  862.     PushWord ItemHit
  863.     _SetDItemValue
  864.     brl ModalLoop
  865.  
  866. SetIt        ; ok was hit so retrieve
  867.     PushWord #0    ; values and save them as default 
  868.     PushLong DialogHandle ; in template for    next time
  869.     PushWord #5
  870.     _GetDItemValue
  871.     PullWord MTRad1Def
  872.  
  873.     PushWord #0
  874.     PushLong DialogHandle
  875.     PushWord #6
  876.     _GetDItemValue
  877.     PullWord MTRad2Def
  878.  
  879.     PushWord #0
  880.     PushLong DialogHandle
  881.     PushWord #7
  882.     _GetDItemValue
  883.     PullWord MTCheckDef
  884.  
  885.     PushLong DialogHandle
  886.     PushWord #8    ; now retrieve the text and use it
  887.     PushLong #MTDefaultStr
  888.     _GetIText
  889.     rts
  890.  
  891. ItemHit    ds.B 2
  892. DialogHandle    ds.B 4
  893.     EndP
  894.  
  895.     END
  896.  
  897.